﻿using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Columns;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZY.EntityFrameWork.Caller;
using ZY.EntityFrameWork.Caller.Facade;
using ZY.EntityFrameWork.Core.Model.Attibutes;
using ZY.EntityFrameWork.Core.Model.Dto;
using ZY.EntityFrameWork.Core.Model.Dto.Authority;

namespace EF_CodeFist
{
    public partial class FormRole : Form
    {
        public FormRole()
        {
            InitializeComponent();
        }

        
        private void FormRole_Load(object sender, EventArgs e)
        {
           // this.gridControl1.DataSource = new BindingList<RoleDto>
                //(CallerFactory.Instance.GetService<IAuthorityService>().GetAllRoles());
            this.gridControl1.DataSource = CallerFactory.Instance.GetService<IArvOpService>().GetArvInLib();

            // 借阅明细表加入“移除”列
            GridColumn unbColumn = new GridColumn();
            unbColumn.FieldName = "Remove";
            unbColumn.Caption = "操作";
            unbColumn.ColumnEdit = repositoryItemButtonEdit1;
            gridView1.Columns.Add(unbColumn);
            unbColumn.VisibleIndex = gridView1.Columns.Count-1;
        }

        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            switch (e.Button.ToolTip)
            {
                case "设置权限":
                    FormPermission frmPermission = new FormPermission();
                    frmPermission.RoleName = ((RoleDto)gridView1.GetFocusedRow()).RoleName;
                    frmPermission.Text = string.Format("设置权限：{0}", frmPermission.RoleName);
                    frmPermission.ShowDialog();
                    break;
            }
        }

        
    }
}
